package ${packagePath};

import com.springcloud.common.utils.ResultVOUtils;
import com.springcloud.common.vo.ResultVO;
import org.springframework.stereotype.Controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

<#-- import List -->
<#list importList as importStr>
${importStr}
</#list>



/**
 * controller
 *
 * @author by fast-code
 * @E-mail liaofuxing@outlook.com
 * @date ${generateDate}
 **/
@Controller
@RequestMapping("/${entityParam}")
public class ${className} {

    @Autowired
    private ${entityService} ${entityServiceParam};

<#if needPagination = true>
    /**
     * 查询部门列表 分页
     *
     * @return ResultVO
     */
    @GetMapping("/get${entity}Page")
    @ResponseBody
    public ResultVO<DatePageVO<${entityVo}>> get${entity}Page(${entityDto} ${entityDtoParam}) {
        DatePageVO<${entityVo}> ${entityVoParam}Page = ${entityServiceParam}.find${entity}Page(${entityDtoParam});
        return ResultVOUtils.success(${entityVoParam}Page);
    }
</#if>

    /**
     * 根据 id 查询 ${entity}
     *
     * @return ResultVO
     */
    @GetMapping("/get${entity}ById")
    @ResponseBody
    public ResultVO<${entity}> get${entity}ById(@RequestParam Integer id) {
        ${entity} ${entityParam}ById = ${entityServiceParam}.find${entity}ById(id);
        return ResultVOUtils.success(${entityParam}ById);
    }

    /**
     * 新增
     *
     * @param ${entityDtoParam} dto
     * @return ResultVO
     */
    @PostMapping("/add${entity}")
    @ResponseBody
    public ResultVO<Object> addDepartment(@RequestBody ${entityDto} ${entityDtoParam}) {
        ${entityServiceParam}.add${entity}(${entityDtoParam});
        return ResultVOUtils.success(null);
    }

    /**
     * 修改
     *
     * @param ${entityDtoParam} dto
     * @return ResultVO
     */
    @PostMapping("/edit${entity}")
    @ResponseBody
    public ResultVO<Object> editDepartment(@RequestBody ${entityDto} ${entityDtoParam}) {
        ${entityServiceParam}.edit${entity}(${entityDtoParam});
        return ResultVOUtils.success(null);
    }
}